<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>工位：切割</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<style>
#code{
	font-size:26px;
	/* width:400px; */
	display:inline-block;
	/* height: 100px; */
}
</style>
<body>
 
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>

<div id="deDivID" hidden="hidden">
	<form class="layui-form layui-card-body" id="addFormID" action="${pageContext.request.contextPath}/breakdown/addDeviceBreakdown.do">
	
		<div class="layui-form-item"><label class="layui-form-label">故障设备名称</label><input class="layui-input" lay-verify="type" type="text" name="deviceName" style="width:300px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">设备编号</label><input class="layui-input" lay-verify="type" type="text" name="deviceNo" style="width:300px;"></div>
		<div class="layui-form-item">
			<label class="layui-form-label">报修部门/车间</label>
			<div class="layui-input-block" style="width:300px">
				<select class="layui-select" name="repairDept" id="repairDept">
					<option value="">请选择</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item"><label class="layui-form-label">报修人</label><input class="layui-input" lay-verify="type" type="text" name="repairMan" style="width:300px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">报修时间</label><input class="layui-input" lay-verify="type" type="text" name="repairTime" id="repairTime" style="width:300px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">报修人填写</label><input class="layui-input" lay-verify="type" type="text" name="repairContent" style="width:300px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">维修参与人员</label><input class="layui-input" lay-verify="type" type="text" name="joinRepairMan" style="width:300px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">维修日期/时间</label><input class="layui-input" lay-verify="type" type="text" name="alreadyRepairTime" id="alreadyRepairTime" style="width:300px;"></div>
	
		<button class="layui-btn layui-btn-blue" lay-submit lay-filter="addForm" id="save" style="margin-left:160px; margin-bottom: 20px">立即提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button>
     </form>
</div>

<div id="ngDivID" hidden="hidden">
	<form class="layui-form layui-card-body" id="formID" action="${pageContext.request.contextPath}/ng/insert.do">
	  	<input type="hidden" name="istation" value="切割">
   		<div class="layui-form-item">
			<label class="layui-form-label">配件名称</label>
			<div class="layui-input-block" style="width:300px">
				<select class="layui-select" name="iname">
					<option value="">请选择</option>
					<option>膜管</option>
					<option>膜丝</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item"><label class="layui-form-label">条码</label><input class="layui-input" lay-verify="type" type="text" name="icode" style="width:300px;"></div>
		<div class="layui-form-item">
			<label class="layui-form-label">配件规格</label>
			<div class="layui-input-block">
 				<input class="layui-input"  lay-verify="type" type="text" name="istandard" style="width:300px;">
 			</div>
		</div>
		<div class="layui-form-item"><label class="layui-form-label">配件批次号</label><input class="layui-input" lay-verify="type" type="text" name="ibatch" style="width:300px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">配件数量</label><input class="layui-input" lay-verify="type" type="text" name="inum" style="width:300px;"></div>
  		<div class="layui-form-item">
  		<label class="layui-form-label">异常描述</label>
  			<div class="layui-input-block">
	  			<input class="layui-input"  lay-verify="type" type="text" name="idescription" style="width:300px;">
  			</div>
  		</div>
  		<button class="layui-btn layui-btn-blue" lay-submit lay-filter="subform" id="save" style="margin-left:160px; margin-bottom: 20px">立即提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button>
	</form>
</div>

<div style="background-color: #0997F7">
	<h2 style="color:#FFF">工位：切割</h2>
</div>
<div style="text-align: center;line-height: 100px;margin-top: 100px">
	<div id="code">
		<label class="layui-form-label" style="margin-left: -110px;">膜管</label>
		<input class="layui-input" type="text" name="ctube" id="g1">
		<label class="layui-form-label" style="margin-left: -250px;width: 430px">A/B面硬度（HD）:</label><br/>
		<div>
			<label class="layui-form-label" style="margin-left: -110px;">A:</label>
			<input class="layui-input" type="text" name="remark">
		</div>
		<label class="layui-form-label" style="margin-left: -110px;">B:</label>
		<input class="layui-input" type="text" name="remark2">
	</div>
	<br/>
	<div class="site-demo-button" id="layerDemo" style="margin-bottom: 0;">
		<button data-method="over" data-type="auto" id="over" class="layui-btn layui-btn-blue">完成</button>
		&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
		<button data-method="baoXui" data-type="auto" id="repair" class="layui-btn layui-btn-blue">设备报修</button>
		&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
		<button data-method="offset" data-type="auto" id="bad" class="layui-btn layui-btn-blue">配件报检</button>
		&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
		<button data-method="baoXui" data-type="auto" id="back" class="layui-btn layui-btn-blue">注销</button>
	</div>
</div>
<div style="position:absolute;bottom:0;width:100%;background-color: #0997F7">
	<h2 style="color:#FFF">作业员：张三</h2>
</div>

<script>

var id = "g1"
function keyDown(e){  
    //IE内核浏览器  
     if (navigator.appName == 'Microsoft Internet Explorer'){  
           var keycode = event.keyCode;  
           var realkey = String.fromCharCode(event.keyCode);  
     }else {//非IE内核浏览器  
           var keycode = e.which;  
           var realkey = String.fromCharCode(e.which);  
     }  
   // console.log('按键码:' + keycode +  '字符: ' + realkey);  

   //监听Ctrl键  
   if(keycode==13){  
	   if($("#icode").val() != null && $("#icode").val() != "" && $("#icode").val() != undefined) {
		   return;
	   }
	   var ctube=$.trim($("#g1").val());
	   
	   if(ctube == "" || ctube == undefined || ctube == null) {
  			return;
  		}else {
  			 $.ajax({
  		    	type:'post',
  		    	url:'${pageContext.request.contextPath }/cut/save.do',
  		    	data: {"ctube":ctube},
  		    	success:function(data){
  		    		if(data>0){
  		    			toastr.success("操作成功！");
  		    		}else if(data == -1) {
  		    			toastr.warning("条码已存在！");
  		    		}else{
  		    			toastr.warning("操作失败！");
  		    		}
  		    	}
  		    })
  		}
   }  
   $("#"+id).change(function(){  
       console.log($(this).val());  
       $("#"+id).select();  
   })  
   
}  
//按键事件
document.onkeydown=keyDown;

layui.use(['table','layer','upload','form'], function(){
  var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
  
   var form = layui.form; 
   form.render();
  
  
  //选择文本框
  $("#"+id).select();
  
  //切割完成
  $('#over').click(function(){   
	  var ctube=$.trim($("#g1").val());
	  $.ajax({
	    	type:'post',
	    	url:'${pageContext.request.contextPath }/cut/save.do',
	    	data: {"ctube":ctube},
	    	success:function(data){
	    		if(data>0){
	    			toastr.success("操作成功！");
	    		}else{
	    			toastr.warning("操作失败！");
	    		}
	    	}
	    })
  });
  
  //设备报修
  $('#repair').click(function(){   
	  layer.open({
		   type: 1 					//Page层类型
	  		,area: ['600px', '650px'] 	//宽  高
	  		,title: '不良品报检'
	  		,shade: 0.6 				//遮罩透明度
	  		,maxmin: true 				//允许全屏最小化
	  		,anim: 1 					//0-6的动画形式，-1不开启
	  		,content: $("#deDivID")
	  		,end: function(){
	  			$("#deDivID").hide();
	  		}
	   		,success:  function(){
               //报修时间
               laydate.render({
                   elem: '#repairTime',
                   format: 'yyyy-MM-dd HH:mm:ss'
               });
             	//维修日期/时间
               laydate.render({
                   elem: '#alreadyRepairTime',
                   format: 'yyyy-MM-dd HH:mm:ss'
               });
             	//下拉框查找所有部门
				$.ajax({
		            type: 'POST',
		            url: '${pageContext.request.contextPath}/device/queryAllDeptList.do',
		            dataType: 'json',
		            async: false,
		            success: function (data){
		                for (var i = 0; i < data.length; i++) {
		                    $("#repairDept").append("<option value='"+ data[i].name +"'>"+ data[i].name +"</option>");
		                }
		            }
		        });
               //初始化radio、select等元素
               form.render();
           }
	   });
   })
   //注销
  $('#back').click(function(){   
 	 
   })
   
    //配件报检
 $('#bad').click(function(){   
	 layer.open({
	   type: 1 					//Page层类型
  		,area: ['500px', '450px'] 	//宽  高
  		,title: '不良品报检'
  		,shade: 0.6 				//遮罩透明度
  		,maxmin: true 				//允许全屏最小化
  		,anim: 1 					//0-6的动画形式，-1不开启
  		,content: $("#ngDivID")
  		,end: function(){
  			$("#ngDivID").hide();
  		}
   		,success: function(layero, index){
       	 this.enterEsc = function(event){
          if(event.keyCode === 13){
            return false; //阻止系统默认回车事件
          }
        }; 
        $(document).on('keydown', this.enterEsc);	//监听键盘事件，关闭层
    }
   });
  })
  
   form.on('submit(addForm)', function (data) {
      var datas=data.field;
   	  var action=data.form.action;
   	  $.ajax({
   		  url:action,
   		  data:datas,
   		  type:"POST",
   		  dataType:"json",
   		  success:function(result){
   			 if(result > 0) {
   				toastr.success("添加成功！");
   				$("#reset").click();
   				setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
					window.location.reload();  
				},2000);
   			 }else {
   				 toastr.warning("添加失败！");
   				 return false;
   			 }
   		  },
   	  });
        return false;
    });
  
  
  form.on('submit(subform)', function (data) {
	  var datas=data.field;
   	  var action=data.form.action;
   	  $.ajax({
   		  url:action,
   		  data:datas,
   		  type:"POST",
   		  dataType:"json",
   		  success:function(result){
   			 if(result > 0) {
   				toastr.success("添加成功！");
   				$("#reset").click();
   				setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
					window.location.reload();  
				},2000);
   			 }else {
   				 toastr.warning("添加失败！");
   				 return false;
   			 }
   		  },
   	  });
   	  
   	  return false;
	  });
  
  toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
});
</script>
</body>
</html>